package com.zking.shiro.service.impl;

import com.zking.shiro.mapper.UserMapper;
import com.zking.shiro.model.User;
import com.zking.shiro.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int doRegister(User user) {
        return userMapper.insert(user);
    }

    @Override
    public User doLogin(User user) {
        return userMapper.doLogin(user);
    }

    @Override
    public int updatePassword(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public int doResetPassword(User user) {
        return userMapper.doResetPassword(user);
    }

    @Override
    public User loadByUsername(User user) {
        return userMapper.doLogin(user);
    }

    @Override
    public Set<String> listPermissionsByUserName(User user) {
        return userMapper.listPermissionsByUserName(user);
    }

    @Override
    public Set<String> listRolesByUserName(User user) {
        return userMapper.listRolesByUserName(user);
    }
}
